﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<HYBYSoft.Company.Models.ArticleAndCategory>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#startTime").attr("readonly", "true").datepicker({ dateFormat: 'yy-mm-dd',
                dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
                dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
            });

            $("#endTime").attr("readonly", "true").datepicker({ dateFormat: 'yy-mm-dd',
                dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
                dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
            });
        });
    </script>
    <div id="content">
        <div id="div_search">
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                    <td id="left_search">
                    </td>
                    <td id="bg_search">
                        <p>
                            <span id="sitemap">当前位置：文章列表</span>
                        </p>
                        <%using (Html.BeginForm("Search", "Article"))
                          {%>
                        <p>
                            文章标题：<%=Html.TextBox("titleDetail", null, new { style = "width:110px;margin-right:15px" })%>
                            分类：<%=Html.DropDownList("ddlCategoryName", (IEnumerable<SelectListItem>)ViewData["categoryName"], new { style = "width:110px;margin-right:15px" })%>起始时间：<%=Html.TextBox("startTime", null, new { style = "width:110px;margin-right:15px" })%>截止时间：<%=Html.TextBox("endTime", null, new { style = "width:110px;margin-right:15px" })%><input
                                type="submit" value="查询" />
                        </p>
                        <%} %>
                    </td>
                    <td id="right_search">
                    </td>
                </tr>
            </table>
        </div>
        <div id="div_list">
            <%if (Model.Count() == 0)
              {
                  Html.RenderPartial("partialNoneDate");
              }
              else
              {%>
            <% var grid = new WebGrid(source: Model, defaultSort: "LastEditTime", rowsPerPage: 10, canSort: false, ajaxUpdateContainerId: "divGrid"); %>
             <div id="divGrid">
            <%=grid.GetHtml(tableStyle: "grid", headerStyle: "header",rowStyle:"row", alternatingRowStyle: "alt", footerStyle: "footer",  mode:WebGridPagerModes.All, firstText:"首页", previousText:"上一页", nextText:"下一页", lastText:"尾页", numericLinksCount:10,columns: grid.Columns(grid.Column("文章标题", format: (item) => Html.ActionLink(((ArticleAndCategory)((WebGridRow)item).Value).Title.Length > 20 ? ((ArticleAndCategory)((WebGridRow)                                                     item).Value).Title.Substring(0, 20) + "..." : ((ArticleAndCategory)((WebGridRow)                                                     item).Value).Title, "Details", new { id = item.ArticleID, pageId = Request.QueryString["page"]  }), style: "titlecolumn"),
                        grid.Column("CategoryName", "文章类别"),
                        grid.Column("Release", "发布状态"),
                        grid.Column("Editor", "创建者"),
                        grid.Column("CreateTime", "创建时间", style: "datecolumn"), 
                        grid.Column("编辑", format: (item) => Html.ActionLink("编辑","Edit", new { id = item.ArticleID , pageId = Request.QueryString["page"] })),
                        grid.Column("删除",format: (item) => Html.ActionLink("删除","Delete", new { id =item.ArticleID },                                                 new { onclick ="return confirm('确定删除该文章？');" }), style:"buttoncolumn"),
                        grid.Column("发布控制", format: (item) => Html.ActionLink                                                                                        (((ArticleAndCategory)((WebGridRow)item).Value).IsRelease==0?"发布":"取消发布",                                                       "Release", new { id = item.ArticleID }, new { onclick = "return confirm('是否确定此操作？');" }), style: "buttoncolumn")))%>
            <%} %>
        </div>
        </div>
        <div id="div_button" style="padding-top: 15px">
            <p>
                <%: Html.ActionLink("创建新文章", "Create", new { pageId = Request.QueryString["page"] })%>
            </p>
        </div>
    </div>
</asp:Content>
